<template>
    <div class="py-18">
        <el-result
                icon="success"
                :title="$t('登录授权')"
                :sub-title="$t('是否授权扫码登录')"
        >
            <template #extra>
                <el-button type="primary" size="medium" @click="closePage">{{$t('取消')}}</el-button>
                <el-button type="primary" size="medium" @click="authorize">{{$t('确定')}}</el-button>
            </template>
        </el-result>
    </div>
</template>

<script>
import wx from "weixin-js-sdk";

    export default {
        name: "LoginAuthorize",
        return:{
            go: '',
            goParam: ''
        },
        
        methods: {
            authorize() {
                this.go = 'LoginAuthorize'
                this.goParam = this.$route.query.goParam
                if(this.goParam ==='' || this.goParam == undefined){
                    return
                }
                this.$axiosSecondary.get('/generateWxloginUrl?go='+this.go + '&goParam=' + this.goParam).then(res=>{
                    const authorizationUrl = res.data
                    window.location.replace(authorizationUrl);
                })
            },
            closePage() {
                wx.closeWindow();
            },
        }
    
    }
</script>